﻿using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace 解释器模式_Message
{
    /// <summary>
    /// 终端公式（TerminalExpression）分析与对象相关的
    /// </summary>
    public class ObjectExpression: AbstractExpression
    {
        /// <summary>
        /// 从输入内容中取得要解释的词
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public override string GetWord(string source)
        {
            MatchCollection mc;
            var r = new Regex(@"\[(.*)\]");
            mc = r.Matches(source);
            return mc[0].Groups[1].Value;
        }

        /// <summary>
        ///  获取与对象相关的字典
        /// </summary>
        /// <returns></returns>
        public override Dictionary<string, string> GetDictionary()
        {
            var d = new Dictionary<string, string>();
            d.Add("信息", "Message");
            return d;
        }
    }
}
